Skip to content

[JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort - #24863

Merged
wing328 merged 19 commits into
OpenAPITools:masterfrom
Picazsoo:feature/allow-autoXSpringPaginated-for-endpoints-without-sort
Sep 27, 2026
Merged

wing328 merged 19 commits into
OpenAPITools:masterfrom
Picazsoo:feature/allow-autoXSpringPaginated-for-endpoints-without-sort

Conversation

@Picazsoo

@Picazsoo Picazsoo commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

autoXSpringPaginated previously only auto-detected Pageable operations that had all three of page, size, and sort query parameters. Many real-world paginated endpoints intentionally omit sort (fixed ordering, or sorting handled elsewhere), so those operations were silently skipped by auto-detection and users had to fall back to manually annotating every such operation with x-spring-paginated: true. A plain boolean also couldn't express "detect with just page/size" without breaking the existing all-three-params behavior for consumers relying on it, so the option is widened to a string enum with an explicit page-size mode, while true/false are kept working (with a deprecation warning) so existing specs and configs don't break.

Change autoXSpringPaginated from a boolean switch into a string-enum option with three canonical values:

  • none: disable auto-detection (default)
  • page-size-sort: require page, size, and sort query parameters (identical to the previous true behavior)
  • page-size: require only page and size; sort may be absent (new)

The legacy true/false values are still accepted as deprecated aliases for page-size-sort/none respectively. A deprecation warning is logged once via the generator logger only when the option is explicitly set to true/false; leaving the option unset keeps the silent none default with no warning.

  • Add SpringPageableScanUtils.AutoPaginationMode enum and resolveAutoPaginationMode() to centralize parsing/validation/deprecation warnings shared by SpringCodegen and KotlinSpringServerCodegen.
  • Update willBePageable, applyAutoXSpringPaginatedIfNeeded, and the scanSortValidationEnums/scanPageableDefaults/scanPageableConstraints/scanAll methods to take AutoPaginationMode instead of boolean.
  • Replace the boolean CLI switch with a documented string-enum CLI option in SpringCodegen and KotlinSpringServerCodegen (JavaCamelServerCodegen inherits the behavior since it extends SpringCodegen).
  • Update existing tests to use the new enum where internal signatures changed; add new tests for page-size mode detection, deprecation warnings (once when explicit, never when unset), and invalid values.
  • Regenerate docs/generators/{spring,kotlin-spring,java-camel}.md.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request: @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10), @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08) @KannaKim (2026/07)

Summary by cubic

Converts autoXSpringPaginated from a boolean switch into a string-enum option so Spring generators can auto-detect Pageable endpoints that have only page and size (no sort). Previously auto-detection required all three parameters; now a page-size mode is available, and the default none disables auto-detection.

  • Accepts canonical values none, page-size-sort, and page-size; page-size-sort matches the old true behavior.
  • Legacy true/false values still work but log a deprecation warning once when explicitly set; the unset default stays silent.
  • Detection counts only query parameters, so a path or header parameter named page, size, or sort no longer triggers auto-detection.
  • Invalid values are rejected even for libraries that don't support Pageable; write-back and usage remain gated by isPageableSupported().
  • Public string and deprecated boolean setters are preserved for both Spring and Kotlin generators; an unset Kotlin option stays out of additionalProperties. The deprecation warning is an instance method on SpringPageableScanUtils so it honors the ArchUnit rule limiting logger use across generator instances.
  • Parsing, validation, and the CLI enum values are centralized in SpringPageableScanUtils and shared by SpringCodegen, KotlinSpringServerCodegen, and JavaCamelServerCodegen.
  • Adds tests for page-size detection, query-parameter filtering, deprecation warnings, invalid values, and setter behavior; deprecation-warning tests filter log events by thread and snapshot them under the appender lock to stay stable under parallel runs.
  • Regenerates generator docs and updates samples.

Written for commit 8aa3102. Summary will update on new commits.

Review in cubic

Change autoXSpringPaginated from a boolean switch into a string-enum option
with three canonical values:

- none: disable auto-detection (default)
- page-size-sort: require page, size, and sort query parameters (identical
  to the previous true behavior)
- page-size: require only page and size; sort may be absent (new)

The legacy true/false values are still accepted as deprecated aliases for
page-size-sort/none respectively. A deprecation warning is logged once via
the generator logger only when the option is explicitly set to true/false;
leaving the option unset keeps the silent none default with no warning.

- Add SpringPageableScanUtils.AutoPaginationMode enum and
  resolveAutoPaginationMode() to centralize parsing/validation/deprecation
  warnings shared by SpringCodegen and KotlinSpringServerCodegen.
- Update willBePageable, applyAutoXSpringPaginatedIfNeeded, and the
  scanSortValidationEnums/scanPageableDefaults/scanPageableConstraints/
  scanAll methods to take AutoPaginationMode instead of boolean.
- Replace the boolean CLI switch with a documented string-enum CLI option
  in SpringCodegen and KotlinSpringServerCodegen (JavaCamelServerCodegen
  inherits the behavior since it extends SpringCodegen).
- Update existing tests to use the new enum where internal signatures
  changed; add new tests for page-size mode detection, deprecation
  warnings (once when explicit, never when unset), and invalid values.
- Regenerate docs/generators/{spring,kotlin-spring,java-camel}.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo Picazsoo changed the title [JAVA-SPRING;KOTLIN-SPRING]Allow autoXSpringPaginated for endpoints without sort [JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort Sep 4, 2026
@Picazsoo
Picazsoo marked this pull request as ready for review September 8, 2026 05:26

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Picazsoo
Picazsoo marked this pull request as draft September 8, 2026 06:05
Preserve public string and deprecated boolean setter APIs for Spring and Kotlin Spring generators. Keep Kotlin autoXSpringPaginated absent from additionalProperties when it is unset, matching Spring behavior. Replace binding-dependent logback test capture with direct setter and option-state assertions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 12:06
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 12:06

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Share the immutable auto-pagination CLI enum map from SpringPageableScanUtils so Spring and Kotlin Spring generators cannot diverge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 12:56
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 12:56
@Picazsoo Picazsoo changed the title [JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort [JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort Sep 9, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Re-trigger cubic

@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 13:16
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 13:17

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

Re-trigger cubic

Picazsoo and others added 3 commits September 9, 2026 16:05
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit c6bcdb2.
@Picazsoo
Picazsoo marked this pull request as ready for review September 9, 2026 16:24
@Picazsoo
Picazsoo marked this pull request as draft September 9, 2026 16:25

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Picazsoo
Picazsoo marked this pull request as ready for review September 22, 2026 09:32

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Requires human review: Auto-approval blocked by 2 unresolved issues from a previous review of this commit.

Re-trigger cubic

- Filter resolved parameters to in:query before checking required
  names in willBePageable(), so non-query parameters named 'page'/
  'size' no longer cause PAGE_SIZE auto-detection false positives.
- Guard the legacy true/false deprecation warning in
  SpringCodegen/KotlinSpringServerCodegen's setAutoXSpringPaginated
  setters with a per-instance flag, so repeated setter/option-
  processing calls only log the warning once.
- Add regression test for path/header parameters named page/size
  not triggering PAGE_SIZE auto-detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

- Restore logback ListAppender tests in SpringCodegenTest and
  KotlinSpringServerCodegenTest asserting the legacy true/false
  deprecation warning is logged exactly once when explicitly set and
  not at all when unset, plus a new test proving the setter's
  once-only guard suppresses a second warning when invoked twice with
  the same legacy value.
- Add willBePageable_pageSizeSortMode_doesNotDetectPathParamNamedSort
  to lock in the query-location filter for PAGE_SIZE_SORT (previously
  only regression-tested for PAGE_SIZE).
- Add .in("query") to the page/size params in
  applyAutoXSpringPaginatedIfNeeded_autoDisabled_doesNotSetExtension
  and applyAutoXSpringPaginatedIfNeeded_explicitlyFalse_returnsFalseAndIsNotOverridden
  so they exercise real auto-detection instead of passing trivially.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Picazsoo and others added 4 commits September 22, 2026 12:22
Surefire runs test classes in parallel (parallel=classes,
threadCountClasses=3), and SpringCodegen/KotlinSpringServerCodegen log
through a shared per-class-name logback Logger inherited by all
subclasses. A ListAppender attached to that logger during these tests
could capture log events emitted by concurrently-running test classes
on other threads, causing flaky/incorrect exactly-once and no-warning
assertions. Filter captured events to the current test thread before
asserting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…arning tests

ListAppender.list is a plain ArrayList that concurrently-running test
classes may still append to. Copy it while holding the appender monitor
(the same lock AppenderBase.doAppend uses) before filtering by thread.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

…logic

- Resolve and validate an explicitly supplied autoXSpringPaginated value
  in SpringCodegen and KotlinSpringServerCodegen regardless of library,
  so invalid values are no longer silently ignored for
  spring-http-interface / spring-declarative-http-interface. Write-back
  and usage remain gated by isPageableSupported().
- Move the once-only deprecation-warning guard into
  SpringPageableScanUtils.warnOnce(Consumer) shared by both generators.
- Extract a countDeprecationWarnings(Runnable) helper in the Spring and
  Kotlin Spring codegen tests, and add regression tests for validation
  on unsupported libraries and for warnOnce.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Picazsoo and others added 5 commits September 23, 2026 22:26
Move the ListAppender attach/detach, monitor-guarded snapshot and
current-thread filtering duplicated in SpringCodegenTest and
KotlinSpringServerCodegenTest into TestUtils.captureLogMessages, leaving
a thin per-class countDeprecationWarnings wrapper.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The setter is only called once per generation (from processOpts), so the
warn-once machinery guarded a case that never occurs in practice.

- Make SpringPageableScanUtils.resolveAutoPaginationMode(String) pure.
- Add package-private warnIfDeprecatedAutoPaginationValue, called once
  from processOpts in SpringCodegen and KotlinSpringServerCodegen; it
  shares value normalization with resolve.
- Remove warnOnce and the per-generator guard fields.
- Adapt tests and drop the ones made redundant by the
  processOpts-logs-exactly-once tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tionValue instance method

LOGGER in SpringPageableScanUtils is intentionally a non-static instance
field (enforced by ArchUnitRulesTest to limit memory use across
generator instances), so it cannot be referenced from a static method.

Change warnIfDeprecatedAutoPaginationValue from static to instance
scope and call it via the existing pageableUtils instance in
SpringCodegen and KotlinSpringServerCodegen. Update the corresponding
unit tests to invoke it on a SpringPageableScanUtils instance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@wing328 wing328 added this to the 7.26.0 milestone Sep 27, 2026
@wing328
wing328 merged commit 979c44b into OpenAPITools:master Sep 27, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants